#include "StdAfx.h"
#include "ClientDaemonCommander.h"

ClientDaemonCommander::ClientDaemonCommander(void)
{
}

ClientDaemonCommander::~ClientDaemonCommander(void)
{
}

int ClientDaemonCommander::ProcessCommand( void )
{
	if (!gClientConnStatus.isOnline())
	{
		return COMMAND_CONN_ERROR;
	}
	CMarkup xmlClientDaemon;
	xmlClientDaemon.AddElem(_T("IPIN")); 
	xmlClientDaemon.AddChildElem(_T("Type"), CLIENT_DAEMON);
	xmlClientDaemon.AddChildElem(_T("Info"));
	xmlClientDaemon.IntoElem();
	xmlClientDaemon.AddChildElem(_T("Name"), gUserInfo.m_UserName.c_str());
	xmlClientDaemon.AddChildElem(_T("Email"), gUserInfo.m_Email.c_str());
	xmlClientDaemon.AddChildElem(_T("UID"), gUserInfo.m_UID.c_str());

	m_Command = xmlClientDaemon.GetDoc();
	int ConnRsp = SendCommand(TRUE);
	if (ConnRsp != CONNECTION_OK)
	{
		return COMMAND_CONN_ERROR;
	}
	return COMMAND_OK;
}